package ${package}.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import ${package}.utils.Result;
import ${package}.entity.${className}Query;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import lombok.AllArgsConstructor;
import ${package}.application.${className}AppService;
import ${package}.vo.${className}VO;
import ${package}.entity.${className}DTO;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Api(tags = "${comments}")
@RestController
@AllArgsConstructor
@RequestMapping("/${apiName}")
public class ${className}Controller {

    private final ${className}AppService ${tableAliasName}AppService;

    @ApiOperation(value = "列表分页查询")
    @PostMapping("/list")
    public Result<IPage<${className}VO>> queryPage(@RequestBody ${className}Query ${tableAliasName}Query) {
        return Result.ok(${tableAliasName}AppService.queryPage(${tableAliasName}Query));
    }

    @ApiOperation(value = "编辑/保存")
    @PostMapping
    public Result<Boolean> saveOrUpdate(@RequestBody ${className}DTO ${tableAliasName}) {
        return Result.ok(${tableAliasName}AppService.saveOrUpdate(${tableAliasName}));
    }

    @ApiOperation(value = "查询数据明细")
    @GetMapping("/{id}")
    public Result<${className}VO> detail(@PathVariable Long id) {
        return Result.ok(${tableAliasName}AppService.detail(id));
    }

    @ApiOperation(value = "根据id删除数据")
    @DeleteMapping("/{id}")
    public Result<Boolean> deleteById(@PathVariable Long id) {
        return Result.ok(${tableAliasName}AppService.deleteById(id));
    }
}